﻿Option Strict On
Option Infer Off
Option Explicit On

Imports System
Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System.Globalization
Imports System.Drawing

'<TypeConverter(GetType(nibConverter))> _
<DefaultProperty("Value")> _
<DefaultBindingProperty("Value")> _
<DefaultValue(GetType(Single), "0")> _
<DefaultEvent("UpdatedValue")> _
<ToolboxBitmap(GetType(TnTinMn.NIB.NumericInputBox), "NumericInputBox.icon.bmp")> _
<Designer("TnTinMn.NIB.Design.NIB_ControlDesigner, TnTinMn.NIB.Design")> _
<System.ComponentModel.Design.Serialization.DesignerSerializer( _
         "TnTinMn.NIB.Design.NIB_CodeDomSerializer, TnTinMn.NIB.Design", _
         "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design")> _
<ToolboxItem(GetType(System.Drawing.Design.ToolboxItem))> _
Public Class NumericInputBox
    Inherits FilteredTextBox

   Implements System.ComponentModel.INotifyPropertyChanged

   Implements System.IConvertible

   Private Const WM_CONTEXTMENU As Int32 = &H7B
   Private Const WM_CHAR As Int32 = &H102

   Public Sub New()

      'components = New System.ComponentModel.Container()

      Me.CausesValidation = True
      Me.CharacterCasing = Windows.Forms.CharacterCasing.Upper
      Me.Multiline = False
      Me.TextAlign = HorizontalAlignment.Right

      My.InDesignMode = (LicenseManager.UsageMode = LicenseUsageMode.Designtime) _
               OrElse Me.DesignMode OrElse _
               (System.Diagnostics.Process.GetCurrentProcess().ProcessName = "devenv")

      'CopyToolStripMenuItem
      '
      CopyToolStripMenuItem.Name = "CopyToolStripMenuItem"
      CopyToolStripMenuItem.Size = New System.Drawing.Size(87, 22)
      CopyToolStripMenuItem.Text = "Copy"
      CopyToolStripMenuItem.DisplayStyle = ToolStripItemDisplayStyle.Text

      '
      'PasteToolStripMenuItem
      '
      PasteToolStripMenuItem.Name = "PasteToolStripMenuItem"
      PasteToolStripMenuItem.Size = New System.Drawing.Size(87, 22)
      PasteToolStripMenuItem.Text = "Paste"
      PasteToolStripMenuItem.DisplayStyle = ToolStripItemDisplayStyle.Text


      'HelpToolStripMenuItem
      HelpToolStripMenuItem.Name = "HelpToolStripMenuItem"
      HelpToolStripMenuItem.Size = New System.Drawing.Size(87, 22)
      HelpToolStripMenuItem.Text = "Help"
      HelpToolStripMenuItem.DisplayStyle = ToolStripItemDisplayStyle.Text

      mycm = New Windows.Forms.ContextMenuStrip()
      With mycm
         .Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.CopyToolStripMenuItem, _
                                                                   Me.PasteToolStripMenuItem, _
                                                                   Me.Seperator, _
                                                                   Me.HelpToolStripMenuItem})
         .Name = "ContextMenuStrip1"
         .ShowImageMargin = False
         .Size = New System.Drawing.Size(88, 48)
      End With

      ShortcutsEnabled = True
      ContextMenuStrip = mycm

      SystemTypeCode = NIBSystemTypes.Double

      ' set previously entered to a generic fmt
      PreviouslyEnteredText = DisplayedFormatProperties.FormatValue(Me._Value, Me, True)

   End Sub

#Region "Events"
   '''<summary>Trap this event to update external variable"</summary>
   <Description("Trap this event to update external variable")> _
   Public Event PropertyChanged(ByVal sender As Object, _
                                ByVal e As System.ComponentModel.PropertyChangedEventArgs) _
                                Implements System.ComponentModel.INotifyPropertyChanged.PropertyChanged

   '''<summary>Raised in Function RangeCheckValue to display message</summary>
   Private Event OutofRange(ByVal msg As String)

   ''' <summary>
   ''' Raised in ReportErr
   ''' </summary>
   ''' <remarks></remarks>
   Public Shared Event InputErr As EventHandler(Of NumericInputBoxErrorArguments)

   <Browsable(False)> _
   <EditorBrowsable(EditorBrowsableState.Never)> _
   Private Shadows Event TextChanged As EventHandler(Of EventArgs)

   Public Event UpdatedValue As EventHandler(Of UpdatedValueEventArgs)

   Public Class UpdatedValueEventArgs
      Inherits EventArgs

      Public ReadOnly OldValue As ValueType
      Public ReadOnly NewValue As ValueType
      Public Sub New(ByVal oldvalue As ValueType, ByVal newvalue As ValueType)
         Me.OldValue = oldvalue
         Me.NewValue = newvalue
      End Sub
   End Class

   ' Do not name this sub ValueChanged, it will mess with databinding
   Private Sub ValueHasChanged(ByVal vcea As UpdatedValueEventArgs)
      'PropertyChanged Raised to notify binding
      RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("Value"))
      RaiseEvent UpdatedValue(Me, vcea)
   End Sub

   Private Sub NumericInputBox_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Leave
      If Not CausesValidation Then
         Dim cea As New CancelEventArgs
         NumericInputBox_Validating(Me, cea)
         If cea.Cancel Then
            Me.Focus()
         Else
            NumericInputBox_Validated(Me, Nothing)
         End If
      End If
   End Sub

   Dim WithEvents b As System.Windows.Forms.Binding

   Private InvalidValue As Boolean
   Sub NumericInputBox_Validating(ByVal sender As Object, ByVal cea As CancelEventArgs) Handles Me.Validating
      If sender Is Me AndAlso Not myFormIsClosing Then

         If Not EntryCommitted Then
            EntryCommitted = CommitEntry()
            If EntryCommitted Then
            End If
         End If
         InvalidValue = Not EntryCommitted
         cea.Cancel = Not EntryCommitted

      End If
      myFormIsClosing = False 'reset if prior FormClosing Canceled
   End Sub

   Private Sub NumericInputBox_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Validated
      ' format the text in accorance with DisplayedFormatProperties
      MyBase.[Text] = DisplayedFormatProperties.FormatValue(Me._Value, Me)
   End Sub

   Private Sub Validate()
      NumericInputBox_Validating(Me, New CancelEventArgs)
   End Sub

   Private myFormIsClosing As Boolean = False

   Private Sub myFormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs)
      If Me.Focused Then myFormIsClosing = True
   End Sub

   Private myform As Form
   Protected Overrides Sub OnHandleCreated(ByVal e As System.EventArgs)
      MyBase.OnHandleCreated(e)
      If myform IsNot Nothing Then
         RemoveHandler myform.FormClosing, AddressOf myFormClosing
      End If
      myform = Me.FindForm
      If myform IsNot Nothing Then
         AddHandler myform.FormClosing, AddressOf myFormClosing
      End If
   End Sub

#End Region

#Region "Properties and Property Helper Methods"

   Private _AdvanceTabStopOnEnter As Boolean = True
   Private _AllowFormToValidate As Boolean = True
   Private _BackColor As Color
   Private _DisplayedFormatProperties As New DisplayedFormatProperties(Me)
   Private _ErrorMessageProperties As New ErrMessageProperties(Me)
   Private _ForeColor As Color
   Private myTypeConverter As System.ComponentModel.TypeConverter
   Private oldvalue As ValueType = _Value
   Friend PreviouslyEnteredText As String = Nothing
   Private _RangeChecking As New RangeCheckProperties(Me)
   Private _SystemType As Type
   Private _SystemTypeCode As NIBSystemTypes = NIBSystemTypes.Single
   Friend TrueSystemTypeCode As System.TypeCode

   Private _Text As String
   Private IsAnInteger As Boolean
   Private _Value As ValueType = 0.0F

   Friend FormattingSupressed As Boolean

   <Description("to simulate the ""Tab"" Key if the user hits the ""Enter"" key")> _
      Public Property AdvanceTabStopOnEnter() As Boolean
      Get
         Return _AdvanceTabStopOnEnter
      End Get
      Set(ByVal value As Boolean)
         _AdvanceTabStopOnEnter = value
      End Set
   End Property

   Public Shadows Property BackColor() As Color
      Get
         Return MyBase.BackColor
      End Get
      Set(ByVal value As Color)
         _BackColor = value
         MyBase.BackColor = value
      End Set
   End Property 'BackColor

   Friend ReadOnly Property BaseText() As String
      Get
         Return MyBase.[Text]
      End Get
   End Property

   Public Shadows Property ForeColor() As Color
      Get
         Return MyBase.ForeColor
      End Get
      Set(ByVal value As Color)
         _ForeColor = value
         MyBase.ForeColor = value
      End Set
   End Property 'ForeColor

   <DisplayName("Value Formatting")> _
   <ExpandablePropertyFlag()> _
   Public Property DisplayedFormatProperties() As DisplayedFormatProperties
      Get
         Return _DisplayedFormatProperties
      End Get
      Set(ByVal value As DisplayedFormatProperties)
         _DisplayedFormatProperties = value
      End Set
   End Property 'DIsplayedFormatProperties

   <DisplayName("Error Message Properties")> _
   <ExpandablePropertyFlag()> _
   Public Property ErrorMessageProperties() As ErrMessageProperties
      Get
         Return _ErrorMessageProperties
      End Get
      Set(ByVal value As ErrMessageProperties)
         _ErrorMessageProperties = value
      End Set
   End Property 'ErrorMessageProperties

   '<TypeConverter(GetType(RangeCheckPropertiesConverter))> _
   <ExpandablePropertyFlag()> _
   Public Property RangeChecking() As RangeCheckProperties
      Get
         Return _RangeChecking
      End Get
      Set(ByVal value As RangeCheckProperties)
         _RangeChecking = value
      End Set
   End Property 'RangeChecking

   Friend WriteOnly Property SetText() As String
      Set(ByVal value As String)
         MyBase.[Text] = value
      End Set
   End Property


   '<DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _
   Friend Property SystemType() As Type
      Get
         Return _SystemType
      End Get
      Private Set(ByVal value As Type)
         _SystemType = value
      End Set
   End Property 'SystemType

   Public Enum NIBSystemTypes As Int32
      [Byte] = System.TypeCode.Byte
      [SByte] = System.TypeCode.SByte
      [Single] = System.TypeCode.Single
      [Double] = System.TypeCode.Double
      [Decimal] = System.TypeCode.Decimal
      [Int16] = System.TypeCode.Int16
      [Int32] = System.TypeCode.Int32
      [Int64] = System.TypeCode.Int64
      [UInt16] = System.TypeCode.UInt16
      [UInt32] = System.TypeCode.UInt32
      [UInt64] = System.TypeCode.UInt64
   End Enum

   <TypeConverter(GetType(NIBSystemTypesEnumConverter))> _
   <Description("Changing this property  will set" & _
   " Value = 0 ,ValueMin = Type.MinValue and " & _
   "ValueMax = Type.MaxValue")> _
   Public Property SystemTypeCode() As NIBSystemTypes
      Get
         Return _SystemTypeCode
      End Get

      Set(ByVal value As NIBSystemTypes)

         If [Enum].IsDefined(GetType(NIBSystemTypes), value) Then
            _SystemTypeCode = value
            SystemType = Type.GetType("System." & CType(value, NumericInputBox.NIBSystemTypes).ToString, True, False)
            TrueSystemTypeCode = Type.GetTypeCode(SystemType)
            myTypeConverter = System.ComponentModel.TypeDescriptor.GetConverter(SystemType)


            Select Case CType(SystemTypeCode, TypeCode)
               Case TypeCode.Int16, TypeCode.Int32, TypeCode.Int64, TypeCode.UInt16, TypeCode.UInt32, TypeCode.UInt64, TypeCode.Byte, TypeCode.SByte
                  Me.IsAnInteger = True
               Case Else
                  Me.IsAnInteger = False
            End Select
            SystemType = Type.GetType("System." & value.ToString, True, False)

            RangeChecking.MaxValue = GetMax(_SystemType)
            RangeChecking.MinValue = GetMin(_SystemType)

            Me.Value = CType(Convert.ChangeType(0, _SystemType), ValueType)
         Else
            Throw New InvalidCastException("NumericInputBox can not be of type: " & value.ToString)
         End If 'AllowedTypes.Contains(value)
      End Set
   End Property

   Public Shadows Property Text() As String
      Get
         If Focused Then
            Return DisplayedFormatProperties.FormatValue(Me._Value, Me)
         Else
            Return MyBase.[Text]
         End If
      End Get
      Set(ByVal value As String)
         Throw New InvalidOperationException("Can not set " & Me.ErrorMessageProperties.ErrName & ".Text")
      End Set
   End Property 'Text

   <DefaultValue(GetType(System.Windows.Forms.HorizontalAlignment), "Right")> _
   Public Shadows Property TextAlign() As System.Windows.Forms.HorizontalAlignment
      Get
         Return MyBase.TextAlign
      End Get
      Set(ByVal value As System.Windows.Forms.HorizontalAlignment)
         MyBase.TextAlign = value
      End Set
   End Property 'TextAlign




   Private OriginalText As String
   <DefaultValueAttribute(0US)> _
   <TypeConverter(GetType(NumericValueTypeConverter))> _
   <System.ComponentModel.Bindable(True)> _
      Public Property Value() As ValueType
         Get
            Return _Value
         End Get
         Set(ByVal value As ValueType)

            Dim ValueIsGood As Boolean
            ValueIsGood = ValidValue(value)

            If ValueIsGood AndAlso Me.RangeChecking.Enabled Then
               'Make sure the new value falls in the specified range
               ValueIsGood = RangeCheckValue(value, False)
            End If

            If ValueIsGood Then
                  Dim vcea As New UpdatedValueEventArgs(_Value, value)
                  _Value = value
                  oldvalue = value

                  ' set previously entered to a generic fmt (G)
                  OriginalText = DisplayedFormatProperties.FormatValue(Me._Value, Me, True)

                  If Me.Focused Then
                     MyBase.[Text] = OriginalText ' set to the generic format of PreviouslyEnteredText
                  Else
                     MyBase.[Text] = DisplayedFormatProperties.FormatValue(Me._Value, Me)
                  End If

                  If Not A_IsEqualTo_B(vcea.OldValue, vcea.NewValue, Me.TrueSystemTypeCode) Then
                     ValueHasChanged(vcea)
                  End If

                  EntryCommitted = True

            Else

               Throw New ArgumentException("Invalid value assigned to " & _
                                            Me.ErrorMessageProperties.ErrName & _
                                            ". Value = " & value.ToString)
            End If
         End Set
      End Property

#Region "Helper Methods For Properties"
   Friend Sub SetBaseColors()
      MyBase.BackColor = _BackColor
      MyBase.ForeColor = _ForeColor
   End Sub

   Friend Sub SetNegativeColors()
      MyBase.BackColor = DisplayedFormatProperties.NegativeBackgroundColor
      MyBase.ForeColor = DisplayedFormatProperties.NegativeForegroundColor
   End Sub

   Public Sub ResumeFormattingUpdates()
      Me.DisplayedFormatProperties.FormattingSupressed = False
      If String.IsNullOrEmpty(OriginalText) Then
         ' OriginalText will be blank due to the default intialization of zero values
         OriginalText = DisplayedFormatProperties.FormatValue(Me._Value, Me, True)
         SelectionStart = OriginalText.Length
      End If
      Me.DisplayedFormatProperties.updateDisplayedText()
   End Sub

   Public Sub SuppressFormattingUpdates()
      Me.DisplayedFormatProperties.FormattingSupressed = True
   End Sub

   ''' <summary>
   ''' Used In Value.Set  Verifies value can be converted to the selected SystemType.
   ''' </summary>
   ''' <param name="value"></param>
   ''' <returns>Boolean - Converted.  Also ByRef converted value is set.</returns>
   ''' <remarks>Called from Property Value.Set</remarks>
   Private Function ValidValue(ByRef value As ValueType) As Boolean
      Try
         If value Is Nothing Then value = 0 'DataBinding passes Nothing
         value = CType(Convert.ChangeType(value, _SystemType), ValueType)
         Return True
      Catch ex As Exception
         Return False
      End Try
   End Function
#End Region

#End Region 'Properties and Property Helper Methods

#Region "Main Keyboard Handling"

   Private Const BackSpace As Char = ChrW(Keys.Back)
   Private EntryCommitted As Boolean = False

   Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
      Select Case m.Msg
         Case WM_CHAR 'The WM_CHAR message contains the character code of the key that was pressed.
            If ConsumeChar(Me, m.WParam.ToInt32) Then
               m.Result = IntPtr.Zero
            Else
               MyBase.WndProc(m)
            End If
         Case WM_CONTEXTMENU
            If Clipboard.ContainsText Then
               Dim strTest As String
               If MyBase.[Text].Length = Me.SelectionStart Then
                  strTest = MyBase.[Text] & Clipboard.GetText
               Else
                  strTest = MyBase.[Text].Substring(0, Me.SelectionStart) & Clipboard.GetText & MyBase.[Text].Substring(Me.SelectionStart + Me.SelectionLength)
               End If
               PasteToolStripMenuItem.Enabled = Microsoft.VisualBasic.IsNumeric(strTest)
            Else
               PasteToolStripMenuItem.Enabled = False
            End If
            'PasteToolStripMenuItem.Enabled = Clipboard.ContainsText
            If Me.SelectionLength = 0 Then
               CopyToolStripMenuItem.Enabled = False
            Else
               CopyToolStripMenuItem.Enabled = True
            End If
            MyBase.WndProc(m)

         Case Else
            MyBase.WndProc(m)
      End Select

   End Sub


   Private Const WM_Copy As Int32 = &H301&
   Private Const WM_Cut As Int32 = &H300&


   'Handle the KeyDown event to determine the type of character entered into the control.
   Private Sub me_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
      If e.KeyCode = Keys.F1 Then
         Help()
         Exit Sub
      End If
      Select Case e.KeyCode
         Case Keys.C
            If e.Modifiers = Keys.Control Then
               Dim msg As New Message With {.HWnd = Me.Handle, .Msg = WM_Copy}
               WndProc(msg)
               e.Handled = True
               Exit Sub
            End If

         Case Keys.V
            If e.Modifiers = Keys.Control Then
               PasteCB()
               e.Handled = True
               Exit Sub
            End If

         Case Keys.Delete
            If e.Modifiers = Keys.Control Then
               Dim msg As New Message With {.HWnd = Me.Handle, .Msg = WM_Cut}
               WndProc(msg)
               e.Handled = True
               Exit Sub
            End If

      End Select
      KeyDownInternal(Me, e)
      EntryCommitted = False
   End Sub 'me_KeyDown

   ''' <summary>Keydown events are trapped for editing only.</summary>
   Private Shared Sub KeyDownInternal(ByVal nib As NumericInputBox, ByRef e As System.Windows.Forms.KeyEventArgs)

      Dim ExponentPos As Integer = nib.BaseText.IndexOf("E")

      Select Case e.KeyCode
         Case Keys.Delete
            Dim ss As Int32 = nib.SelectionStart
            e.SuppressKeyPress = False
            If nib.SelectedText.Length < nib.TextLength Then
               If (ss < nib.BaseText.Length AndAlso nib.BaseText(ss) = "E"c) OrElse nib.SelectedText.Contains("E") Then
                  nib.SetText = (nib.BaseText).Substring(0, ss)
                  nib.SelectionStart = nib.BaseText.Length
                  e.SuppressKeyPress = True
               End If
            End If


         Case Keys.Back
            'Only concern is if deleting the exponent "E" char
            'if it is to be deleted, delete the entire exponent
            If ExponentPos > -1 AndAlso nib.SelectionStart = ExponentPos + 1 Then
               nib.SetText = nib.BaseText.Substring(0, ExponentPos)
               nib.SelectionStart = nib.BaseText.Length
               e.SuppressKeyPress = True
            End If

         Case Keys.Escape
            nib._Value = nib.oldvalue
            nib.SetText = nib.OriginalText
            nib.SelectionStart = nib.BaseText.Length

         Case Keys.Enter

             'If nib.CommitEntry() Then
                  If nib._AdvanceTabStopOnEnter Then
                     Dim res As Boolean = nib.FindForm.SelectNextControl(nib, True, True, True, True)
                  Else
                     nib.Validate()
                  End If
             'End If

            e.SuppressKeyPress = True

         Case Keys.C, Keys.V
            If e.Control Then
               e.SuppressKeyPress = False
            Else
               e.SuppressKeyPress = True
            End If

      End Select

   End Sub 'me_KeyDown

   Private Function CommitEntry() As Boolean
      PreviouslyEnteredText = MyBase.[Text]

      EntryCommitted = False
      ' 1st check for valid entry
      Dim EnteredValue As ValueType = Nothing          ' var to Recieve converted text
      Dim ex As New Exception                          ' var to return conversion exception
      InvalidValue = True                              ' Clear if valid

      If TextIsValidForType(MyBase.[Text], Me, EnteredValue, ex) Then

         If Me.RangeChecking.Enabled AndAlso Not RangeCheckValue(EnteredValue, True) Then
            Return False
         End If

         EntryCommitted = True                         ' reached this point all is well
         Dim vcea As New UpdatedValueEventArgs(oldvalue, EnteredValue)
         Dim notify As Boolean = Not A_IsEqualTo_B(oldvalue, EnteredValue, Me.TrueSystemTypeCode)

         Me.SelectionStart = MyBase.[Text].Length        ' Move caret to end of entry
         _Value = EnteredValue                           ' save the Entered Value
         oldvalue = _Value                               ' set the oldvalue to current

         OriginalText = MyBase.[Text]                           ' set OriginalText to current
         If notify Then
            ValueHasChanged(vcea)
         End If
         InvalidValue = False
         Return EntryCommitted                                       ' Entry commited

      Else                                             ' Text is not valid
         If ex.InnerException IsNot Nothing Then       ' display exception message
            ReportErr(Me, ex.InnerException.Message, NumericInputBoxErrorArguments.ErrorType.InvalidInputFormat)
         Else
            ReportErr(Me, ex.Message, NumericInputBoxErrorArguments.ErrorType.InvalidInputFormat)
         End If
         Return EntryCommitted                                  ' Entry not committed
      End If ' TextIsValidForType(MyBase.[Text], Me, EnteredValue, ex)

   End Function

   ''' <summary>called from WndProc on receiving the WM_CHAR message</summary>
   Private Shared Function ConsumeChar(ByVal nib As NumericInputBox, ByVal charcode As Int32) As Boolean

      Dim ExponentPos As Integer = nib.BaseText.IndexOf("E")
      Dim pressed As Char = ChrW(charcode)
      Dim decimalpt As Char = nib.DisplayedFormatProperties.FormatCultureInForce.NumberFormat.NumberDecimalSeparator(0)

      Select Case pressed

         Case "0"c To "9"c
             If nib.SelectionStart = 0 AndAlso nib.BaseText.Length > 0 AndAlso _
                nib.BaseText.Substring(0, 1) = "-" _
                AndAlso nib.SelectionLength = 1 Then
                 'prevent entering number in front of minus sign
                 Return True
             Else
                 Return False
             End If

         Case "E"c, "e"c 'Exponent
            If nib.IsAnInteger Then Return True
            If ExponentPos >= 1 Then
               Return True
            Else
               If (nib.BaseText).Length = 0 OrElse _
                  ((nib.BaseText)(0) = "-"c AndAlso nib.SelectionStart = 1) _
                  OrElse nib.SelectionStart = 0 Then
                  Return True
               Else
                  Return False
               End If
            End If

         Case BackSpace
            'pass it on to the textbox
            Return False

         Case "-"c

            'only allow in 1st position or in 1st pos after Exponent char "E" For NonInteger
            If nib.RangeChecking.AllowNegative AndAlso nib.SelectionStart = 0 Then
               Return False
            End If

            If ExponentPos >= 1 AndAlso nib.SelectionStart = ExponentPos + 1 Then
               Return False
            End If

            Return True

         Case decimalpt 'nib.DisplayedFormatProperties.FormatCultureInForce.NumberFormat.NumberDecimalSeparator(0)

            If nib.IsAnInteger Then
               Return True

            Else
               'If nib.[Text].IndexOf(Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator(0)) = -1 Then
               If nib.BaseText.IndexOf(decimalpt) = -1 Then

                  If nib.SelectionStart = 0 And nib.BaseText.Length > 0 AndAlso nib.BaseText.Substring(0, 1) = "-" Then
                      Return True
                  Else
                      Return False
                  End If 'nib.SelectionStart = 0 And nib.BaseText.Length > 0 AndAlso nib.BaseText.Substring(0, 1) = "-"
               Else
                  Return True
               End If 'nib.[Text].IndexOf(Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator(0)) = -1 
            End If 'nib.IsAnInteger

         Case nib.DisplayedFormatProperties.FormatCultureInForce.NumberFormat.NumberGroupSeparator(0)
            Return False
         Case Else
            Return True

      End Select

   End Function 'ConsumeChar

   Private Shared Function TextIsValidForType(ByVal text As String, _
                                              ByVal nib As NumericInputBox, _
                                              Optional ByRef convertedvalue As ValueType = Nothing, _
                                              Optional ByRef exception As Exception = Nothing) As Boolean
      ' Rules:
      '        1 - Only one decimal allowed for float types (noninteger).
      '        2 - Can have any number of group separators to the left of the decimal mark
      '        3 - Group separators to the right of the decimal mark should be invalid, but
      '            will ignore them.

      If nib.DisplayedFormatProperties.BlankZero AndAlso String.IsNullOrEmpty(text) Then
         convertedvalue = 0
         Return True
      End If

      text = text.Replace(nib.DisplayedFormatProperties.FormatCultureInForce.NumberFormat.NumberGroupSeparator(0), String.Empty)
      Try
         convertedvalue = CType(nib.myTypeConverter.ConvertFromString(Nothing, nib.DisplayedFormatProperties.FormatCultureInForce, text), ValueType)
         Return True
      Catch ex As Exception
         exception = ex
         Return False
      End Try

   End Function

   Private Shared Sub ReportErr(ByVal nib As NumericInputBox, _
                                ByVal msg As String, _
                                ByVal errtype As NumericInputBoxErrorArguments.ErrorType)

      ' Will always raise the error event
      Dim e As New NumericInputBoxErrorArguments(msg, errtype)
      RaiseEvent InputErr(nib, e)
      If nib.ErrorMessageProperties.DisplayMessageBox <> ErrMessageProperties.MessageBoxDisplayMode.DoNotDisplay Then

         InfoBox.Show(msg, _
                      nib, _
                      nib.ErrorMessageProperties.ErrName, _
                      MessageBoxButtons.OK, Icon.Error, _
                      nib.ErrorMessageProperties.InputBoxAnchorPoint, _
                      nib.ErrorMessageProperties.DisplayedMessageBoxAnchorPoint, _
                      (nib.ErrorMessageProperties.DisplayMessageBox = ErrMessageProperties.MessageBoxDisplayMode.DisplayWithOutBeep))


      End If

   End Sub 'ReportErr

   Private Sub NumericInputBox_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Enter
      myFormIsClosing = False 'reset if prior FormClosing Canceled
      If InvalidValue Then
         MyBase.[Text] = PreviouslyEnteredText
         SelectionStart = PreviouslyEnteredText.Length
      Else
         MyBase.[Text] = OriginalText
         SelectionStart = OriginalText.Length
      End If

      SelectionLength = 0
      EntryCommitted = False
      SetBaseColors()
   End Sub

#End Region 'Main Keyboard Handling

#Region "Validation"

   Private Function RangeCheckValue(ByVal EnterValue As ValueType, ByVal Verbose As Boolean) As Boolean

      ' Check that the EnterValue satisfies the MaxValue Limit
         Select Case RangeChecking.MaxComparisonType
            Case RangeCheckProperties.MaxComparison.ValueLessThanMax
               ' EnterValue must be < MaxValue

               If Not A_IsLessThan_B(EnterValue, RangeChecking.MaxValue, Me.TrueSystemTypeCode) Then
                  If Verbose Then
                     RaiseEvent OutofRange(" must be < " & RangeChecking.MaxValue.ToString)
                     ReportErr(Me, " must be < " & RangeChecking.MaxValue.ToString, NumericInputBoxErrorArguments.ErrorType.ValueGreaterThanMax)
                  End If
                  Return False
               End If

            Case RangeCheckProperties.MaxComparison.ValueLessThanOrEqualToMax
               ' EnterValue must be <= MaxValue
                If Not A_IsLessThanOrEqualTo_B(EnterValue, RangeChecking.MaxValue, Me.TrueSystemTypeCode) Then
                  If Verbose Then
                     RaiseEvent OutofRange(" must be <= " & RangeChecking.MaxValue.ToString)
                     ReportErr(Me, " must be <= " & RangeChecking.MaxValue.ToString, NumericInputBoxErrorArguments.ErrorType.ValueGreaterThanMax)

                  End If
                  Return False
                End If
         End Select


      ' Check that the EnterValue satisfies the MinValue Limit
         Select Case RangeChecking.MinComparisonType
            Case RangeCheckProperties.MinComparison.MinLessThanValue
               'MinValue must be < EnteredValue
                If Not A_IsLessThan_B(RangeChecking.MinValue, EnterValue, Me.TrueSystemTypeCode) Then
                  If Verbose Then
                     RaiseEvent OutofRange(" must be > " & RangeChecking.MinValue.ToString)
                     ReportErr(Me, " must be > " & RangeChecking.MinValue.ToString, NumericInputBoxErrorArguments.ErrorType.ValueLessThanMin)
                  End If
                  Return False
                End If

            Case RangeCheckProperties.MinComparison.MinLessThanOrEqualToValue
               'MinValue must be <= EnteredValue
               If Not A_IsLessThanOrEqualTo_B(RangeChecking.MinValue, EnterValue, Me.TrueSystemTypeCode) Then
                  If Verbose Then
                     RaiseEvent OutofRange(" must be >= " & RangeChecking.MinValue.ToString)
                     ReportErr(Me, " must be >= " & RangeChecking.MinValue.ToString, NumericInputBoxErrorArguments.ErrorType.ValueLessThanMin)

                  End If
                  Return False
               End If
         End Select

         Return True ' Passes Range Checking

   End Function 'RangeCheckValue


#End Region 'Validation

#Region "Context Menu"
   Friend WithEvents mycm As Windows.Forms.ContextMenuStrip
   Friend WithEvents CopyToolStripMenuItem As New System.Windows.Forms.ToolStripMenuItem
   Friend WithEvents PasteToolStripMenuItem As New System.Windows.Forms.ToolStripMenuItem
   Friend Seperator As New System.Windows.Forms.ToolStripSeparator
   Friend WithEvents HelpToolStripMenuItem As New System.Windows.Forms.ToolStripMenuItem
   Private Shared HelpForm As NIBEntryHelp


   Private Sub CopyToolStripMenuItem_Click _
         (ByVal sender As System.Object, ByVal e As System.EventArgs) _
         Handles CopyToolStripMenuItem.Click
      If Me.SelectionLength > 0 Then Clipboard.SetText(Me.SelectedText)
   End Sub

   Private Sub PasteCB()
      'Validate text to paste
         If Me.ReadOnly = True Then Exit Sub
         If Not Microsoft.VisualBasic.IsNumeric(Clipboard.GetText) Then
            Exit Sub
         Else
            Dim pasteText As String = Clipboard.GetText
            Me.Paste()
         End If
   End Sub

   Private Sub PasteToolStripMenuItem_Click _
         (ByVal sender As System.Object, ByVal e As System.EventArgs) _
         Handles PasteToolStripMenuItem.Click
      PasteCB()
   End Sub

    Friend Function IsLayoutSuspended(ByVal c As Control) As Boolean
      IsLayoutSuspended = False
      'need check all the way up the parent tree

      Do
         IsLayoutSuspended = _
               CBool(GetType(Control).GetProperty("IsLayoutSuspended", _
                     System.Reflection.BindingFlags.NonPublic Or _
                     System.Reflection.BindingFlags.Instance). _
                     GetValue(c, Nothing))

         c = c.Parent
      Loop Until (c Is Nothing) OrElse IsLayoutSuspended

   End Function

   Private Sub NumericInputBox_ReadOnlyChanged(ByVal sender As Object, _
      ByVal e As System.EventArgs) Handles Me.ReadOnlyChanged
      If Me.ReadOnly Then
         mycm.Enabled = False
      Else
         mycm.Enabled = True
      End If
   End Sub
#End Region

#Region "Type Casting Data & Routines"

   Friend Shared AllowedTypes() As Type = _
            { _
            GetType(System.Byte), _
            GetType(System.Double), _
            GetType(System.Decimal), _
            GetType(System.Int16), _
            GetType(System.Int32), _
            GetType(System.Int64), _
            GetType(System.SByte), _
            GetType(System.Single), _
            GetType(System.UInt16), _
            GetType(System.UInt32), _
            GetType(System.UInt64) _
            }

   Friend Shared Function A_IsEqualTo_B(ByVal A As ValueType, ByVal b As ValueType, ByVal tc As TypeCode) As Boolean
      Select Case tc
         Case TypeCode.Int16
            Return CType(A, Int16) = CType(b, Int16)

         Case TypeCode.Int32
            Return CType(A, Int32) = CType(b, Int32)

         Case TypeCode.Int64
            Return CType(A, Int64) = CType(b, Int64)

         Case TypeCode.UInt16
            Return CType(A, UInt16) = CType(b, UInt16)

         Case TypeCode.UInt32
            Return CType(A, UInt32) = CType(b, UInt32)

         Case TypeCode.UInt64
            Return CType(A, UInt64) = CType(b, UInt64)

         Case TypeCode.Single
            Return CType(A, Single) = CType(b, Single)

         Case TypeCode.Double
            Return CType(A, Double) = CType(b, Double)

         Case TypeCode.Decimal
            Return CType(A, Decimal) = CType(b, Decimal)

         Case TypeCode.Byte
            Return CType(A, Byte) = CType(b, Byte)

         Case TypeCode.SByte
            Return CType(A, SByte) = CType(b, SByte)
      End Select
   End Function

   Friend Shared Function A_IsGreaterThan_B(ByVal A As ValueType, ByVal b As ValueType, ByVal tc As TypeCode) As Boolean
      Select Case tc
         Case TypeCode.Int16
            Return CType(A, Int16) > CType(b, Int16)

         Case TypeCode.Int32
            Return CType(A, Int32) > CType(b, Int32)

         Case TypeCode.Int64
            Return CType(A, Int64) > CType(b, Int64)

         Case TypeCode.UInt16
            Return CType(A, UInt16) > CType(b, UInt16)

         Case TypeCode.UInt32
            Return CType(A, UInt32) > CType(b, UInt32)

         Case TypeCode.UInt64
            Return CType(A, UInt64) > CType(b, UInt64)

         Case TypeCode.Single
            Return CType(A, Single) > CType(b, Single)

         Case TypeCode.Double
            Return CType(A, Double) > CType(b, Double)

         Case TypeCode.Decimal
            Return CType(A, Decimal) > CType(b, Decimal)

         Case TypeCode.Byte
            Return CType(A, Byte) > CType(b, Byte)

         Case TypeCode.SByte
            Return CType(A, SByte) > CType(b, SByte)
      End Select
   End Function

   Friend Shared Function A_IsGreaterThanOrEqualTo_B(ByVal A As ValueType, ByVal b As ValueType, ByVal tc As TypeCode) As Boolean
      Select Case tc
         Case TypeCode.Int16
            Return CType(A, Int16) >= CType(b, Int16)

         Case TypeCode.Int32
            Return CType(A, Int32) >= CType(b, Int32)

         Case TypeCode.Int64
            Return CType(A, Int64) >= CType(b, Int64)

         Case TypeCode.UInt16
            Return CType(A, UInt16) >= CType(b, UInt16)

         Case TypeCode.UInt32
            Return CType(A, UInt32) >= CType(b, UInt32)

         Case TypeCode.UInt64
            Return CType(A, UInt64) >= CType(b, UInt64)

         Case TypeCode.Single
            Return CType(A, Single) >= CType(b, Single)

         Case TypeCode.Double
            Return CType(A, Double) >= CType(b, Double)

         Case TypeCode.Decimal
            Return CType(A, Decimal) >= CType(b, Decimal)

         Case TypeCode.Byte
            Return CType(A, Byte) >= CType(b, Byte)

         Case TypeCode.SByte
            Return CType(A, SByte) >= CType(b, SByte)
      End Select
   End Function

   Friend Shared Function A_IsLessThan_B(ByVal A As ValueType, ByVal B As ValueType, ByVal tc As TypeCode) As Boolean
      Select Case tc
         Case TypeCode.Int16
            Return CType(A, Int16) < CType(B, Int16)

         Case TypeCode.Int32
            Return CType(A, Int32) < CType(B, Int32)

         Case TypeCode.Int64
            Return CType(A, Int64) < CType(B, Int64)

         Case TypeCode.UInt16
            Return CType(A, UInt16) < CType(B, UInt16)

         Case TypeCode.UInt32
            Return CType(A, UInt32) < CType(B, UInt32)

         Case TypeCode.UInt64
            Return CType(A, UInt64) < CType(B, UInt64)

         Case TypeCode.Single
            Return CType(A, Single) < CType(B, Single)

         Case TypeCode.Double
            Return CType(A, Double) < CType(B, Double)

         Case TypeCode.Decimal
            Return CType(A, Decimal) < CType(B, Decimal)

         Case TypeCode.Byte
            Return CType(A, Byte) < CType(B, Byte)

         Case TypeCode.SByte
            Return CType(A, SByte) < CType(B, SByte)
      End Select
   End Function

   Friend Shared Function A_IsLessThanOrEqualTo_B(ByVal A As ValueType, ByVal B As ValueType, ByVal tc As TypeCode) As Boolean
      Select Case tc
         Case TypeCode.Int16
            Return CType(A, Int16) <= CType(B, Int16)

         Case TypeCode.Int32
            Return CType(A, Int32) <= CType(B, Int32)

         Case TypeCode.Int64
            Return CType(A, Int64) <= CType(B, Int64)

         Case TypeCode.UInt16
            Return CType(A, UInt16) <= CType(B, UInt16)

         Case TypeCode.UInt32
            Return CType(A, UInt32) <= CType(B, UInt32)

         Case TypeCode.UInt64
            Return CType(A, UInt64) <= CType(B, UInt64)

         Case TypeCode.Single
            Return CType(A, Single) <= CType(B, Single)

         Case TypeCode.Double
            Return CType(A, Double) <= CType(B, Double)

         Case TypeCode.Decimal
            Return CType(A, Decimal) <= CType(B, Decimal)

         Case TypeCode.Byte
            Return CType(A, Byte) <= CType(B, Byte)

         Case TypeCode.SByte
            Return CType(A, SByte) <= CType(B, SByte)
      End Select
   End Function

   Friend Shared Function GetMax(ByVal t As Type) As ValueType
      Return CType(t.GetField("MaxValue", Reflection.BindingFlags.Static Or Reflection.BindingFlags.Public).GetValue(Nothing), ValueType)
   End Function

   Friend Shared Function GetMin(ByVal t As Type) As ValueType
      Return CType(t.GetField("MinValue", Reflection.BindingFlags.Static Or Reflection.BindingFlags.Public).GetValue(Nothing), ValueType)
   End Function

   Public Function ToInt16() As Int16
      Return CType(Value, Int16)
   End Function

   Public Function ToInt32() As Int32
      Return CType(Value, Int32)
   End Function

   Public Function ToInt64() As Int64
      Return CType(Value, Int64)
   End Function

   Public Function ToUInt16() As UInt16
      Return CType(Value, UInt16)
   End Function

   Public Function ToUInt32() As UInt32
      Return CType(Value, UInt32)
   End Function

   Public Function ToUInt64() As UInt64
      Return CType(Value, UInt64)
   End Function

   Public Function ToDecimal() As Decimal
      Return CType(Value, Decimal)
   End Function

   Public Function ToDouble() As Double
     Return CType(Value, Double)
   End Function

   Public Function ToSingle() As Single
      Return CType(Value, Single)
   End Function

   Public Function ToByte() As Byte
      Return CType(Me.Value, Byte)
   End Function

   Public Function ToSByte() As SByte
      Return CType(Me.Value, SByte)
   End Function

   Public Overrides Function ToString() As String
      Return Me.Value.ToString()
   End Function

#End Region '"Type Casting Properties & Routines"

#Region "System.IConvertible"

   ' These are implemented to support System.Convert
   Public Function GetTypeCode() As System.TypeCode Implements System.IConvertible.GetTypeCode
      Return TypeCode.Object
   End Function

   Private Function ToBoolean(ByVal provider As System.IFormatProvider) As Boolean Implements System.IConvertible.ToBoolean
      Throw New InvalidCastException("NumericInputBox.ToBoolean not supported")
   End Function

   Private Function ToByte1(ByVal provider As System.IFormatProvider) As Byte Implements System.IConvertible.ToByte
      Return Me.ToByte
   End Function

   Private Function ToChar(ByVal provider As System.IFormatProvider) As Char Implements System.IConvertible.ToChar
      Throw New InvalidCastException("NumericInputBox.ToChar not supported")
   End Function

   Private Function ToDateTime(ByVal provider As System.IFormatProvider) As Date Implements System.IConvertible.ToDateTime
      Throw New InvalidCastException("NumericInputBox.ToDateTime not supported")
   End Function

   Private Function ToDecimal1(ByVal provider As System.IFormatProvider) As Decimal Implements System.IConvertible.ToDecimal
      Return Me.ToDecimal
   End Function

   Private Function ToDouble1(ByVal provider As System.IFormatProvider) As Double Implements System.IConvertible.ToDouble
      Return Me.ToDouble
   End Function

   Private Function ToInt161(ByVal provider As System.IFormatProvider) As Short Implements System.IConvertible.ToInt16
      Return Me.ToInt16
   End Function

   Private Function ToInt321(ByVal provider As System.IFormatProvider) As Integer Implements System.IConvertible.ToInt32
      Return Me.ToInt32
   End Function

   Private Function ToInt641(ByVal provider As System.IFormatProvider) As Long Implements System.IConvertible.ToInt64
      Return Me.ToInt64
   End Function

   Private Function ToSByte1(ByVal provider As System.IFormatProvider) As SByte Implements System.IConvertible.ToSByte
      Return Me.ToSByte
   End Function

   Private Function ToSingle1(ByVal provider As System.IFormatProvider) As Single Implements System.IConvertible.ToSingle
      Return Me.ToSingle
   End Function

   Private Function ToString1(ByVal provider As System.IFormatProvider) As String Implements System.IConvertible.ToString
      Return Me.Value.ToString()
   End Function

   Public Function ToType(ByVal conversionType As System.Type, _
                          ByVal provider As System.IFormatProvider) As Object Implements System.IConvertible.ToType
      Select Case Type.GetTypeCode(conversionType)
         Case TypeCode.Byte
            Return Me.ToByte

         Case TypeCode.SByte
            Return Me.ToSByte

         Case TypeCode.Int16
            Return Me.ToInt16

         Case TypeCode.Int32
            Return Me.ToInt32

         Case TypeCode.Int64
            Return Me.ToInt64

         Case TypeCode.UInt16
            Return Me.ToUInt16

         Case TypeCode.UInt32
            Return Me.ToUInt32

         Case TypeCode.UInt64
            Return Me.ToUInt64

         Case TypeCode.Single
            Return Me.ToSingle

         Case TypeCode.Double
            Return Me.ToDouble

         Case TypeCode.Decimal
            Return Me.ToDecimal
         Case Else
            Throw New InvalidCastException("NumericInputBox.To_" & conversionType.Name & " is not supported")
      End Select
   End Function

   Private Function ToUInt161(ByVal provider As System.IFormatProvider) As UShort Implements System.IConvertible.ToUInt16
      Return Me.ToUInt16
   End Function

   Private Function ToUInt321(ByVal provider As System.IFormatProvider) As UInteger Implements System.IConvertible.ToUInt32
      Return Me.ToUInt32
   End Function

   Private Function ToUInt641(ByVal provider As System.IFormatProvider) As ULong Implements System.IConvertible.ToUInt64
      Return Me.ToUInt64
   End Function
#End Region 'System.IConvertible

#Region "Comparisons"

#Region "Byte"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As Byte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As Byte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As Byte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As Byte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As Byte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As Byte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator

#End Region '"Byte"

#Region "SByte"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As SByte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As SByte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As SByte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As SByte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As SByte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As SByte) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator

#End Region '"SByte"

#Region "Decimal"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As Decimal) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As Decimal) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As Decimal) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As Decimal) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As Decimal) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As Decimal) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator

#End Region '"Decimal"

#Region "Single"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As Single) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As Single) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As Single) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As Single) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As Single) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As Single) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator

#End Region '"Single"

#Region "Double"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As Double) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As Double) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As Double) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As Double) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As Double) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As Double) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator
#End Region '"Double"

#Region "Int16"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As Int16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As Int16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As Int16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As Int16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As Int16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As Int16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator
#End Region '"Int16"

#Region "Int32"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As Int32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As Int32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As Int32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As Int32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As Int32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As Int32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator

#End Region '"Int32"

#Region "Int64"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As Int64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As Int64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As Int64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As Int64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As Int64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As Int64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator
#End Region '"Int64"

#Region "UInt16"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As UInt16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As UInt16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As UInt16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As UInt16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As UInt16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As UInt16) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator
#End Region '"UInt16"

#Region "UInt32"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As UInt32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.Double
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As UInt32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As UInt32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As UInt32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As UInt32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As UInt32) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator

#End Region '"UInt32"

#Region "UInt64"

   Public Overloads Shared Operator =(ByVal n As NumericInputBox, ByVal number As UInt64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) = number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) = number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) = number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) = number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) = number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) = number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) = number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) = number

         Case TypeCode.Single
            Return CType(n.Value, Single) = number

         Case TypeCode.UInt64
            Return CType(n.Value, Double) = number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) = number

      End Select
   End Operator

   Public Overloads Shared Operator <>(ByVal n As NumericInputBox, ByVal number As UInt64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <> number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <> number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <> number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <> number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <> number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <> number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <> number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <> number

         Case TypeCode.Single
            Return CType(n.Value, Single) <> number

         Case TypeCode.Double
            Return CType(n.Value, Double) <> number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <> number

      End Select
   End Operator

   Public Overloads Shared Operator >(ByVal n As NumericInputBox, ByVal number As UInt64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) > number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) > number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) > number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) > number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) > number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) > number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) > number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) > number

         Case TypeCode.Single
            Return CType(n.Value, Single) > number

         Case TypeCode.Double
            Return CType(n.Value, Double) > number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) > number

      End Select
   End Operator

   Public Overloads Shared Operator >=(ByVal n As NumericInputBox, ByVal number As UInt64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) >= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) >= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) >= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) >= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) >= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) >= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) >= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) >= number

         Case TypeCode.Single
            Return CType(n.Value, Single) >= number

         Case TypeCode.Double
            Return CType(n.Value, Double) >= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) >= number

      End Select
   End Operator

   Public Overloads Shared Operator <(ByVal n As NumericInputBox, ByVal number As UInt64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) < number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) < number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) < number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) < number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) < number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) < number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) < number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) < number

         Case TypeCode.Single
            Return CType(n.Value, Single) < number

         Case TypeCode.Double
            Return CType(n.Value, Double) < number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) < number

      End Select
   End Operator

   Public Overloads Shared Operator <=(ByVal n As NumericInputBox, ByVal number As UInt64) As Boolean
      Select Case Type.GetTypeCode(n.SystemType)
         Case TypeCode.SByte
            Return CType(n.Value, SByte) <= number

         Case TypeCode.Byte
            Return CType(n.Value, Byte) <= number

         Case TypeCode.Int16
            Return CType(n.Value, Int16) <= number

         Case TypeCode.Int32
            Return CType(n.Value, Int32) <= number

         Case TypeCode.Int64
            Return CType(n.Value, Int64) <= number

         Case TypeCode.UInt16
            Return CType(n.Value, UInt16) <= number

         Case TypeCode.UInt32
            Return CType(n.Value, UInt32) <= number

         Case TypeCode.UInt64
            Return CType(n.Value, UInt64) <= number

         Case TypeCode.Single
            Return CType(n.Value, Single) <= number

         Case TypeCode.Double
            Return CType(n.Value, Double) <= number

         Case TypeCode.Decimal
            Return CType(n.Value, Decimal) <= number

      End Select
   End Operator
#End Region '"UInt64"

#End Region '"Comparisons"

#Region "Widening Operators"
   Private Shared Sub WideningError(ByVal n As NumericInputBox, ByVal ToType As TypeCode)
         Throw New InvalidCastException(n.ErrorMessageProperties.ErrName & _
         "(" & n.SystemType.Name & ") can not widen to " & ToType.ToString)
   End Sub

   'A widening conversion changes a value to a data type that can accommodate any possible value of the original data. 
   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As SByte
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.SByte) Then
         Return CType(n.Value, SByte)
      Else
         WideningError(n, TypeCode.SByte)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As Byte
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.Byte) Then
         Return CType(n.Value, Byte)
      Else
         WideningError(n, TypeCode.Byte)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As Int16
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.Int16) Then
         Return CType(n.Value, Int16)
      Else
         WideningError(n, TypeCode.Int16)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As Int32
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.Int32) Then
         Return CType(n.Value, Int32)
      Else
         WideningError(n, TypeCode.Int32)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As Int64
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.Int64) Then
         Return CType(n.Value, Int64)
      Else
         WideningError(n, TypeCode.Int64)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As UInt16
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.UInt16) Then
         Return CType(n.Value, UInt16)
      Else
         WideningError(n, TypeCode.UInt16)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As UInt32
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.UInt32) Then
         Return CType(n.Value, UInt32)
      Else
         WideningError(n, TypeCode.UInt32)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As UInt64
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.UInt64) Then
         Return CType(n.Value, UInt64)
      Else
         WideningError(n, TypeCode.UInt64)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As Decimal
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.Decimal) Then
         Return CType(n.Value, Decimal)
      Else
         WideningError(n, TypeCode.Decimal)
      End If
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As Double
      'Everything can widen to Double
      Return CType(n.Value, Double)
   End Operator

   Public Shared Widening Operator CType(ByVal n As NumericInputBox) As Single
      If CanWidenTo(n.TrueSystemTypeCode, TypeCode.Single) Then
         Return CType(n.Value, Single)
      Else
         WideningError(n, TypeCode.Single)
      End If
   End Operator

   'Public Shared Widening Operator CType(ByVal n As NumericInputBox) As ValueType
   '   Return n.Value
   'End Operator

#End Region 'Widening Operators

   Private Shared Function CanWidenTo(ByVal sourcetype As TypeCode, ByVal destinationtype As TypeCode) As Boolean

      Select Case sourcetype

         Case TypeCode.SByte
         ' SByte, Short, Integer, Long, Decimal, Single, Double
               Select Case destinationtype
                  Case TypeCode.SByte, TypeCode.Int16, TypeCode.Int32, TypeCode.Int64, _
                        TypeCode.Decimal, TypeCode.Single, TypeCode.Double
                     Return True
                  Case Else
                     Return False
               End Select

         Case TypeCode.Byte
         '  Byte, Short, UShort, Integer, UInteger, Long, ULong, Decimal, Single, Double
            Select Case destinationtype
               Case TypeCode.Byte, TypeCode.Int16, TypeCode.Int32, _
                    TypeCode.UInt32, TypeCode.Int64, TypeCode.UInt64, TypeCode.Decimal, TypeCode.Single, _
                    TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select

         Case TypeCode.Int16
         '  Short, Integer, Long, Decimal, Single, Double
            Select Case destinationtype
               Case TypeCode.Int16, TypeCode.Int32, TypeCode.Int64, _
                    TypeCode.Decimal, TypeCode.Single, TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select

         Case TypeCode.Int32
         '  Integer, Long, Decimal, Single, Double
            Select Case destinationtype
               Case TypeCode.Int32, TypeCode.Int64, TypeCode.Single, TypeCode.Decimal, TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select

         Case TypeCode.Int64
         ' Long, Decimal, Single, Double
            Select Case destinationtype
               Case TypeCode.Int64, TypeCode.Decimal, TypeCode.Single, TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select

         Case TypeCode.UInt16
         '  UShort, Integer, UInteger, Long, ULong, Decimal, Single, Double
            Select Case destinationtype
               Case TypeCode.UInt16, TypeCode.Int32, TypeCode.UInt32, _
                    TypeCode.Int64, TypeCode.UInt64, TypeCode.Decimal, _
                    TypeCode.Single, TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select


         Case TypeCode.UInt32
         '  UInteger, Long, ULong, Decimal, Single, Double
            Select Case destinationtype
               Case TypeCode.UInt32, TypeCode.Int64, TypeCode.UInt64, _
                    TypeCode.Decimal, TypeCode.Single, TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select

         Case TypeCode.UInt64
         '  ULong, Decimal, Single, Double
            Select Case destinationtype
               Case TypeCode.UInt64, TypeCode.Decimal, TypeCode.Single, TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select

         Case TypeCode.Single
         '   Single, Double
            Select Case destinationtype
               Case TypeCode.Single, TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select

         Case TypeCode.Double
         '  Double
            Select Case destinationtype
               Case TypeCode.Double
                  Return True
               Case Else
                  Return False
            End Select

         Case TypeCode.Decimal
         '  Decimal, Single, Double
            Select Case destinationtype
               Case TypeCode.Decimal, TypeCode.Single, TypeCode.Double
                  Return True
               Case Else
                  Return False
           End Select

         Case Else
            Return False
      End Select ' sourcetype
   End Function 'CanWidenTo

   Private Shared Sub MathError(ByVal nib As NumericInputBox, ByVal [operator] As String, ByVal paramtype As TypeCode, ByVal returntype As TypeCode)
         Throw New InvalidCastException("Widening Error on NumericInputBox: " & nib.Name & "(" & nib.TrueSystemTypeCode.ToString & _
                                       "); Operator: " & [operator] & "; " & "Parameter Type " & _
                                       paramtype.ToString & "; Return Type: " & returntype.ToString)
   End Sub

#Region "Int Math"

#Region "Math For Byte"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return nib.ToInt64 + CType(i, Int64)
      Else
         MathError(nib, "+", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(i, Int64) + nib.ToInt64
      Else
         MathError(nib, "+", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return nib.ToInt64 - CType(i, Int64)
      Else
         MathError(nib, "-", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(i, Int64) - nib.ToInt64
      Else
         MathError(nib, "-", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return nib.ToInt64 * CType(i, Int64)
      Else
         MathError(nib, "*", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(i, Int64) * nib.ToInt64
      Else
         MathError(nib, "*", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(nib.ToInt64 / CType(i, Int64), Int64)
      Else
         MathError(nib, "/", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(CType(i, Int64) / nib.ToInt64, Int64)
      Else
         MathError(nib, "/", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return nib.ToInt64 Mod CType(i, Int64)
      Else
         MathError(nib, "Mod", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(i, Int64) Mod nib.ToInt64
      Else
         MathError(nib, "Mod", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(nib.ToInt64 ^ CType(i, Int64), Int64)
      Else
         MathError(nib, "^", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(CType(i, Int64) ^ nib.ToInt64, Int64)
      Else
         MathError(nib, "^", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator \(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return nib.ToInt64 \ CType(i, Int64)
      Else
         MathError(nib, "\", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator \(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(i, Int64) \ nib.ToInt64
      Else
         MathError(nib, "\", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator And(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return nib.ToInt64 And CType(i, Int64)
      Else
         MathError(nib, "And", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator And(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(i, Int64) And nib.ToInt64
      Else
         MathError(nib, "And", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Or(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return nib.ToInt64 Or CType(i, Int64)
      Else
         MathError(nib, "Or", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Or(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(i, Int64) Or nib.ToInt64
      Else
         MathError(nib, "Or", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Xor(ByVal nib As NumericInputBox, ByVal i As Byte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return nib.ToInt64 Xor CType(i, Int64)
      Else
         MathError(nib, "Xor", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Xor(ByVal i As Byte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Byte, TypeCode.Int64) Then
         Return CType(i, Int64) Xor nib.ToInt64
      Else
         MathError(nib, "Xor", TypeCode.Byte, TypeCode.Int64)
      End If
   End Operator
'***********

#End Region 'Math For Byte

#Region "Math For SByte"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return nib.ToInt64 + CType(i, Int64)
      Else
         MathError(nib, "+", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(i, Int64) + nib.ToInt64
      Else
         MathError(nib, "+", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return nib.ToInt64 - CType(i, Int64)
      Else
         MathError(nib, "-", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(i, Int64) - nib.ToInt64
      Else
         MathError(nib, "-", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return nib.ToInt64 * CType(i, Int64)
      Else
         MathError(nib, "*", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(i, Int64) * nib.ToInt64
      Else
         MathError(nib, "*", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(nib.ToInt64 / CType(i, Int64), Int64)
      Else
         MathError(nib, "/", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(CType(i, Int64) / nib.ToInt64, Int64)
      Else
         MathError(nib, "/", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return nib.ToInt64 Mod CType(i, Int64)
      Else
         MathError(nib, "Mod", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(i, Int64) Mod nib.ToInt64
      Else
         MathError(nib, "Mod", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(nib.ToInt64 ^ CType(i, Int64), Int64)
      Else
         MathError(nib, "^", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(CType(i, Int64) ^ nib.ToInt64, Int64)
      Else
         MathError(nib, "^", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator \(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return nib.ToInt64 \ CType(i, Int64)
      Else
         MathError(nib, "\", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator \(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(i, Int64) \ nib.ToInt64
      Else
         MathError(nib, "\", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator And(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return nib.ToInt64 And CType(i, Int64)
      Else
         MathError(nib, "And", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator And(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(i, Int64) And nib.ToInt64
      Else
         MathError(nib, "And", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Or(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return nib.ToInt64 Or CType(i, Int64)
      Else
         MathError(nib, "Or", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Or(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(i, Int64) Or nib.ToInt64
      Else
         MathError(nib, "Or", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Xor(ByVal nib As NumericInputBox, ByVal i As SByte) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return nib.ToInt64 Xor CType(i, Int64)
      Else
         MathError(nib, "Xor", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Xor(ByVal i As SByte, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.SByte, TypeCode.Int64) Then
         Return CType(i, Int64) Xor nib.ToInt64
      Else
         MathError(nib, "Xor", TypeCode.SByte, TypeCode.Int64)
      End If
   End Operator
'***********

#End Region 'Math For SByte

#Region "Math For Int16"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return nib.ToInt64 + CType(i, Int64)
      Else
         MathError(nib, "+", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(i, Int64) + nib.ToInt64
      Else
         MathError(nib, "+", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return nib.ToInt64 - CType(i, Int64)
      Else
         MathError(nib, "-", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(i, Int64) - nib.ToInt64
      Else
         MathError(nib, "-", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return nib.ToInt64 * CType(i, Int64)
      Else
         MathError(nib, "*", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(i, Int64) * nib.ToInt64
      Else
         MathError(nib, "*", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(nib.ToInt64 / CType(i, Int64), Int64)
      Else
         MathError(nib, "/", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(CType(i, Int64) / nib.ToInt64, Int64)
      Else
         MathError(nib, "/", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return nib.ToInt64 Mod CType(i, Int64)
      Else
         MathError(nib, "Mod", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(i, Int64) Mod nib.ToInt64
      Else
         MathError(nib, "Mod", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(nib.ToInt64 ^ CType(i, Int64), Int64)
      Else
         MathError(nib, "^", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(CType(i, Int64) ^ nib.ToInt64, Int64)
      Else
         MathError(nib, "^", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator \(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return nib.ToInt64 \ CType(i, Int64)
      Else
         MathError(nib, "\", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator \(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(i, Int64) \ nib.ToInt64
      Else
         MathError(nib, "\", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator And(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return nib.ToInt64 And CType(i, Int64)
      Else
         MathError(nib, "And", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator And(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(i, Int64) And nib.ToInt64
      Else
         MathError(nib, "And", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Or(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return nib.ToInt64 Or CType(i, Int64)
      Else
         MathError(nib, "Or", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Or(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(i, Int64) Or nib.ToInt64
      Else
         MathError(nib, "Or", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Xor(ByVal nib As NumericInputBox, ByVal i As Int16) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return nib.ToInt64 Xor CType(i, Int64)
      Else
         MathError(nib, "Xor", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Xor(ByVal i As Int16, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int16, TypeCode.Int64) Then
         Return CType(i, Int64) Xor nib.ToInt64
      Else
         MathError(nib, "Xor", TypeCode.Int16, TypeCode.Int64)
      End If
   End Operator
'***********

#End Region 'Math For Int16

#Region "Math For Int32"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return nib.ToInt64 + CType(i, Int64)
      Else
         MathError(nib, "+", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(i, Int64) + nib.ToInt64
      Else
         MathError(nib, "+", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return nib.ToInt64 - CType(i, Int64)
      Else
         MathError(nib, "-", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(i, Int64) - nib.ToInt64
      Else
         MathError(nib, "-", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return nib.ToInt64 * CType(i, Int64)
      Else
         MathError(nib, "*", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(i, Int64) * nib.ToInt64
      Else
         MathError(nib, "*", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(nib.ToInt64 / CType(i, Int64), Int64)
      Else
         MathError(nib, "/", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(CType(i, Int64) / nib.ToInt64, Int64)
      Else
         MathError(nib, "/", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return nib.ToInt64 Mod CType(i, Int64)
      Else
         MathError(nib, "Mod", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(i, Int64) Mod nib.ToInt64
      Else
         MathError(nib, "Mod", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(nib.ToInt64 ^ CType(i, Int64), Int64)
      Else
         MathError(nib, "^", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(CType(i, Int64) ^ nib.ToInt64, Int64)
      Else
         MathError(nib, "^", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator \(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return nib.ToInt64 \ CType(i, Int64)
      Else
         MathError(nib, "\", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator \(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(i, Int64) \ nib.ToInt64
      Else
         MathError(nib, "\", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator And(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return nib.ToInt64 And CType(i, Int64)
      Else
         MathError(nib, "And", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator And(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(i, Int64) And nib.ToInt64
      Else
         MathError(nib, "And", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Or(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return nib.ToInt64 Or CType(i, Int64)
      Else
         MathError(nib, "Or", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Or(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(i, Int64) Or nib.ToInt64
      Else
         MathError(nib, "Or", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Xor(ByVal nib As NumericInputBox, ByVal i As Int32) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return nib.ToInt64 Xor CType(i, Int64)
      Else
         MathError(nib, "Xor", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Xor(ByVal i As Int32, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int32, TypeCode.Int64) Then
         Return CType(i, Int64) Xor nib.ToInt64
      Else
         MathError(nib, "Xor", TypeCode.Int32, TypeCode.Int64)
      End If
   End Operator
'***********

#End Region 'Math For Int32

#Region "Math For Int64"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return nib.ToInt64 + CType(i, Int64)
      Else
         MathError(nib, "+", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(i, Int64) + nib.ToInt64
      Else
         MathError(nib, "+", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return nib.ToInt64 - CType(i, Int64)
      Else
         MathError(nib, "-", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(i, Int64) - nib.ToInt64
      Else
         MathError(nib, "-", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return nib.ToInt64 * CType(i, Int64)
      Else
         MathError(nib, "*", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(i, Int64) * nib.ToInt64
      Else
         MathError(nib, "*", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(nib.ToInt64 / CType(i, Int64), Int64)
      Else
         MathError(nib, "/", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(CType(i, Int64) / nib.ToInt64, Int64)
      Else
         MathError(nib, "/", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return nib.ToInt64 Mod CType(i, Int64)
      Else
         MathError(nib, "Mod", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(i, Int64) Mod nib.ToInt64
      Else
         MathError(nib, "Mod", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(nib.ToInt64 ^ CType(i, Int64), Int64)
      Else
         MathError(nib, "^", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(CType(i, Int64) ^ nib.ToInt64, Int64)
      Else
         MathError(nib, "^", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator \(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return nib.ToInt64 \ CType(i, Int64)
      Else
         MathError(nib, "\", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator \(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(i, Int64) \ nib.ToInt64
      Else
         MathError(nib, "\", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator And(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return nib.ToInt64 And CType(i, Int64)
      Else
         MathError(nib, "And", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator And(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(i, Int64) And nib.ToInt64
      Else
         MathError(nib, "And", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Or(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return nib.ToInt64 Or CType(i, Int64)
      Else
         MathError(nib, "Or", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Or(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(i, Int64) Or nib.ToInt64
      Else
         MathError(nib, "Or", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Xor(ByVal nib As NumericInputBox, ByVal i As Int64) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return nib.ToInt64 Xor CType(i, Int64)
      Else
         MathError(nib, "Xor", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator

   Public Overloads Shared Operator Xor(ByVal i As Int64, ByVal nib As NumericInputBox) As Int64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Int64) AndAlso CanWidenTo(TypeCode.Int64, TypeCode.Int64) Then
         Return CType(i, Int64) Xor nib.ToInt64
      Else
         MathError(nib, "Xor", TypeCode.Int64, TypeCode.Int64)
      End If
   End Operator
'***********

#End Region 'Math For Int64
#End Region 'Int Math

#Region "UInt Math"

#Region "Math For UInt16"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return nib.ToUInt64 + CType(i, UInt64)
      Else
         MathError(nib, "+", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(i, UInt64) + nib.ToUInt64
      Else
         MathError(nib, "+", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return nib.ToUInt64 - CType(i, UInt64)
      Else
         MathError(nib, "-", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(i, UInt64) - nib.ToUInt64
      Else
         MathError(nib, "-", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return nib.ToUInt64 * CType(i, UInt64)
      Else
         MathError(nib, "*", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(i, UInt64) * nib.ToUInt64
      Else
         MathError(nib, "*", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(nib.ToUInt64 / CType(i, UInt64), UInt64)
      Else
         MathError(nib, "/", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(CType(i, UInt64) / nib.ToUInt64, UInt64)
      Else
         MathError(nib, "/", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return nib.ToUInt64 Mod CType(i, UInt64)
      Else
         MathError(nib, "Mod", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(i, UInt64) Mod nib.ToUInt64
      Else
         MathError(nib, "Mod", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(nib.ToUInt64 ^ CType(i, UInt64), UInt64)
      Else
         MathError(nib, "^", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(CType(i, UInt64) ^ nib.ToUInt64, UInt64)
      Else
         MathError(nib, "^", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator \(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return nib.ToUInt64 \ CType(i, UInt64)
      Else
         MathError(nib, "\", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator \(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(i, UInt64) \ nib.ToUInt64
      Else
         MathError(nib, "\", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator And(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return nib.ToUInt64 And CType(i, UInt64)
      Else
         MathError(nib, "And", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator And(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(i, UInt64) And nib.ToUInt64
      Else
         MathError(nib, "And", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Or(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return nib.ToUInt64 Or CType(i, UInt64)
      Else
         MathError(nib, "Or", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Or(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(i, UInt64) Or nib.ToUInt64
      Else
         MathError(nib, "Or", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Xor(ByVal nib As NumericInputBox, ByVal i As UInt16) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return nib.ToUInt64 Xor CType(i, UInt64)
      Else
         MathError(nib, "Xor", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Xor(ByVal i As UInt16, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt16, TypeCode.UInt64) Then
         Return CType(i, UInt64) Xor nib.ToUInt64
      Else
         MathError(nib, "Xor", TypeCode.UInt16, TypeCode.UInt64)
      End If
   End Operator
'***********

#End Region 'Math For UInt16

#Region "Math For UInt32"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return nib.ToUInt64 + CType(i, UInt64)
      Else
         MathError(nib, "+", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(i, UInt64) + nib.ToUInt64
      Else
         MathError(nib, "+", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return nib.ToUInt64 - CType(i, UInt64)
      Else
         MathError(nib, "-", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(i, UInt64) - nib.ToUInt64
      Else
         MathError(nib, "-", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return nib.ToUInt64 * CType(i, UInt64)
      Else
         MathError(nib, "*", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(i, UInt64) * nib.ToUInt64
      Else
         MathError(nib, "*", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(nib.ToUInt64 / CType(i, UInt64), UInt64)
      Else
         MathError(nib, "/", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(CType(i, UInt64) / nib.ToUInt64, UInt64)
      Else
         MathError(nib, "/", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return nib.ToUInt64 Mod CType(i, UInt64)
      Else
         MathError(nib, "Mod", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(i, UInt64) Mod nib.ToUInt64
      Else
         MathError(nib, "Mod", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(nib.ToUInt64 ^ CType(i, UInt64), UInt64)
      Else
         MathError(nib, "^", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(CType(i, UInt64) ^ nib.ToUInt64, UInt64)
      Else
         MathError(nib, "^", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator \(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return nib.ToUInt64 \ CType(i, UInt64)
      Else
         MathError(nib, "\", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator \(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(i, UInt64) \ nib.ToUInt64
      Else
         MathError(nib, "\", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator And(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return nib.ToUInt64 And CType(i, UInt64)
      Else
         MathError(nib, "And", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator And(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(i, UInt64) And nib.ToUInt64
      Else
         MathError(nib, "And", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Or(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return nib.ToUInt64 Or CType(i, UInt64)
      Else
         MathError(nib, "Or", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Or(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(i, UInt64) Or nib.ToUInt64
      Else
         MathError(nib, "Or", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Xor(ByVal nib As NumericInputBox, ByVal i As UInt32) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return nib.ToUInt64 Xor CType(i, UInt64)
      Else
         MathError(nib, "Xor", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Xor(ByVal i As UInt32, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt32, TypeCode.UInt64) Then
         Return CType(i, UInt64) Xor nib.ToUInt64
      Else
         MathError(nib, "Xor", TypeCode.UInt32, TypeCode.UInt64)
      End If
   End Operator
'***********

#End Region 'Math For UInt32

#Region "Math For Uint64"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return nib.ToUInt64 + CType(i, UInt64)
      Else
         MathError(nib, "+", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(i, UInt64) + nib.ToUInt64
      Else
         MathError(nib, "+", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return nib.ToUInt64 - CType(i, UInt64)
      Else
         MathError(nib, "-", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(i, UInt64) - nib.ToUInt64
      Else
         MathError(nib, "-", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return nib.ToUInt64 * CType(i, UInt64)
      Else
         MathError(nib, "*", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(i, UInt64) * nib.ToUInt64
      Else
         MathError(nib, "*", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(nib.ToUInt64 / CType(i, UInt64), UInt64)
      Else
         MathError(nib, "/", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(CType(i, UInt64) / nib.ToUInt64, UInt64)
      Else
         MathError(nib, "/", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return nib.ToUInt64 Mod CType(i, UInt64)
      Else
         MathError(nib, "Mod", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(i, UInt64) Mod nib.ToUInt64
      Else
         MathError(nib, "Mod", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(nib.ToUInt64 ^ CType(i, UInt64), UInt64)
      Else
         MathError(nib, "^", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(CType(i, UInt64) ^ nib.ToUInt64, UInt64)
      Else
         MathError(nib, "^", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator \(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return nib.ToUInt64 \ CType(i, UInt64)
      Else
         MathError(nib, "\", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator \(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(i, UInt64) \ nib.ToUInt64
      Else
         MathError(nib, "\", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator And(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return nib.ToUInt64 And CType(i, UInt64)
      Else
         MathError(nib, "And", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator And(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(i, UInt64) And nib.ToUInt64
      Else
         MathError(nib, "And", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Or(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return nib.ToUInt64 Or CType(i, UInt64)
      Else
         MathError(nib, "Or", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Or(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(i, UInt64) Or nib.ToUInt64
      Else
         MathError(nib, "Or", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Xor(ByVal nib As NumericInputBox, ByVal i As UInt64) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return nib.ToUInt64 Xor CType(i, UInt64)
      Else
         MathError(nib, "Xor", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator

   Public Overloads Shared Operator Xor(ByVal i As UInt64, ByVal nib As NumericInputBox) As UInt64
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.UInt64) AndAlso CanWidenTo(TypeCode.UInt64, TypeCode.UInt64) Then
         Return CType(i, UInt64) Xor nib.ToUInt64
      Else
         MathError(nib, "Xor", TypeCode.UInt64, TypeCode.UInt64)
      End If
   End Operator
'***********

#End Region 'Math For Uint64

#End Region 'UInt Math

#Region "Float Math"

#Region "Math For Double"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As Double) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return nib.ToDouble + CType(i, Double)
      Else
         MathError(nib, "+", TypeCode.Double, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As Double, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return CType(i, Double) + nib.ToDouble
      Else
         MathError(nib, "+", TypeCode.Double, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As Double) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return nib.ToDouble - CType(i, Double)
      Else
         MathError(nib, "-", TypeCode.Double, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As Double, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return CType(i, Double) - nib.ToDouble
      Else
         MathError(nib, "-", TypeCode.Double, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As Double) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return nib.ToDouble * CType(i, Double)
      Else
         MathError(nib, "*", TypeCode.Double, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As Double, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return CType(i, Double) * nib.ToDouble
      Else
         MathError(nib, "*", TypeCode.Double, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As Double) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return nib.ToDouble / CType(i, Double)
      Else
         MathError(nib, "/", TypeCode.Double, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As Double, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return CType(i, Double) / nib.ToDouble
      Else
         MathError(nib, "/", TypeCode.Double, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As Double) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return nib.ToDouble Mod CType(i, Double)
      Else
         MathError(nib, "Mod", TypeCode.Double, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As Double, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return CType(i, Double) Mod nib.ToDouble
      Else
         MathError(nib, "Mod", TypeCode.Double, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As Double) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return nib.ToDouble ^ CType(i, Double)
      Else
         MathError(nib, "^", TypeCode.Double, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As Double, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Double, TypeCode.Double) Then
         Return CType(i, Double) ^ nib.ToDouble
      Else
         MathError(nib, "^", TypeCode.Double, TypeCode.Double)
      End If
   End Operator
'***********

#End Region 'Math For Double

#Region "Math For Single"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As Single) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return nib.ToDouble + CType(i, Double)
      Else
         MathError(nib, "+", TypeCode.Single, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As Single, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return CType(i, Double) + nib.ToDouble
      Else
         MathError(nib, "+", TypeCode.Single, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As Single) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return nib.ToDouble - CType(i, Double)
      Else
         MathError(nib, "-", TypeCode.Single, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As Single, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return CType(i, Double) - nib.ToDouble
      Else
         MathError(nib, "-", TypeCode.Single, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As Single) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return nib.ToDouble * CType(i, Double)
      Else
         MathError(nib, "*", TypeCode.Single, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As Single, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return CType(i, Double) * nib.ToDouble
      Else
         MathError(nib, "*", TypeCode.Single, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As Single) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return nib.ToDouble / CType(i, Double)
      Else
         MathError(nib, "/", TypeCode.Single, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As Single, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return CType(i, Double) / nib.ToDouble
      Else
         MathError(nib, "/", TypeCode.Single, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As Single) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return nib.ToDouble Mod CType(i, Double)
      Else
         MathError(nib, "Mod", TypeCode.Single, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As Single, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return CType(i, Double) Mod nib.ToDouble
      Else
         MathError(nib, "Mod", TypeCode.Single, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As Single) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return nib.ToDouble ^ CType(i, Double)
      Else
         MathError(nib, "^", TypeCode.Single, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As Single, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Single, TypeCode.Double) Then
         Return CType(i, Double) ^ nib.ToDouble
      Else
         MathError(nib, "^", TypeCode.Single, TypeCode.Double)
      End If
   End Operator
'***********

#End Region 'Math For Single

#Region "Math For Decimal"
'***********
   Public Overloads Shared Operator +(ByVal nib As NumericInputBox, ByVal i As Decimal) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return nib.ToDouble + CType(i, Double)
      Else
         MathError(nib, "+", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator +(ByVal i As Decimal, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return CType(i, Double) + nib.ToDouble
      Else
         MathError(nib, "+", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator -(ByVal nib As NumericInputBox, ByVal i As Decimal) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return nib.ToDouble - CType(i, Double)
      Else
         MathError(nib, "-", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator -(ByVal i As Decimal, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return CType(i, Double) - nib.ToDouble
      Else
         MathError(nib, "-", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator *(ByVal nib As NumericInputBox, ByVal i As Decimal) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return nib.ToDouble * CType(i, Double)
      Else
         MathError(nib, "*", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator *(ByVal i As Decimal, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return CType(i, Double) * nib.ToDouble
      Else
         MathError(nib, "*", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator /(ByVal nib As NumericInputBox, ByVal i As Decimal) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return nib.ToDouble / CType(i, Double)
      Else
         MathError(nib, "/", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator /(ByVal i As Decimal, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return CType(i, Double) / nib.ToDouble
      Else
         MathError(nib, "/", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator Mod(ByVal nib As NumericInputBox, ByVal i As Decimal) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return nib.ToDouble Mod CType(i, Double)
      Else
         MathError(nib, "Mod", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator Mod(ByVal i As Decimal, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return CType(i, Double) Mod nib.ToDouble
      Else
         MathError(nib, "Mod", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator
'***********

'***********
   Public Overloads Shared Operator ^(ByVal nib As NumericInputBox, ByVal i As Decimal) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return nib.ToDouble ^ CType(i, Double)
      Else
         MathError(nib, "^", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator

   Public Overloads Shared Operator ^(ByVal i As Decimal, ByVal nib As NumericInputBox) As Double
      If CanWidenTo(nib.TrueSystemTypeCode, TypeCode.Double) AndAlso CanWidenTo(TypeCode.Decimal, TypeCode.Double) Then
         Return CType(i, Double) ^ nib.ToDouble
      Else
         MathError(nib, "^", TypeCode.Decimal, TypeCode.Double)
      End If
   End Operator
'***********

#End Region 'Math For Decimal

#End Region ' Float Math


#Region "Math For NIB"
 '***********
   Public Overloads Shared Operator +(ByVal nib1 As NumericInputBox, ByVal nib2 As NumericInputBox) As Double
      Return CType(nib1.Value, Double) + CType(nib2.Value, Double)
   End Operator

   Public Overloads Shared Operator -(ByVal nib1 As NumericInputBox, ByVal nib2 As NumericInputBox) As Double
      Return CType(nib1.Value, Double) - CType(nib2.Value, Double)
   End Operator

   Public Overloads Shared Operator *(ByVal nib1 As NumericInputBox, ByVal nib2 As NumericInputBox) As Double
      Return CType(nib1.Value, Double) * CType(nib2.Value, Double)
   End Operator

   Public Overloads Shared Operator /(ByVal nib1 As NumericInputBox, ByVal nib2 As NumericInputBox) As Double
      Return CType(nib1.Value, Double) / CType(nib2.Value, Double)
   End Operator

   Public Overloads Shared Operator Mod(ByVal nib1 As NumericInputBox, ByVal nib2 As NumericInputBox) As Double
      Return CType(nib1.Value, Double) Mod CType(nib2.Value, Double)
   End Operator


   Public Overloads Shared Operator ^(ByVal nib1 As NumericInputBox, ByVal nib2 As NumericInputBox) As Double
      Return CType(nib1.Value, Double) ^ CType(nib2.Value, Double)
   End Operator

#End Region 'Math For NIB


   Private Sub HelpToolStripMenuItem_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles HelpToolStripMenuItem.MouseDown
      Help()
   End Sub
   Private Sub Help()
      If HelpForm Is Nothing OrElse HelpForm.IsDisposed Then
         HelpForm = New NIBEntryHelp
      End If

      Dim myForm As Form = Me.FindForm
      If myForm IsNot Nothing Then HelpForm.Owner = myForm
      If HelpForm.IsHandleCreated Then
         HelpForm.Focus()
      Else
         HelpForm.Show()
      End If
   End Sub
End Class

